﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using Fantacid303.ProcessAffinityControl.Config;

namespace Fantacid303.ProcessAffinityControl.Service
{
	static class Program
	{

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		static void Main(string[] args)
		{
/*

			var mgr = new ConfigurationManager();
			mgr.CreateDefaultConfiguration();*/


/*
			var cfgManager = new ConfigurationManager();
			cfgManager.Configuration.Interval = 1000;



			//cfgManager.Save();

			



			return;*/


			try
			{
				var arg = args.Length == 0 ? string.Empty : args[0].ToLower();

				switch (arg)
				{
					case "":
					case "--service":
						var servicesToRun = new ServiceBase[] { new ProcessControlService() };
						ServiceBase.Run(servicesToRun);
						break;
					case "--debug":
						var service = new ProcessControlService();
						service.StartService();

						Console.WriteLine("Service is running. Hit ENTER to shut down the service: ");
						Console.ReadLine();
						service.StopService();

						break;

					default:
						throw new ApplicationException("Invalid command line argument: " + args[0]);
				}
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.Message);
			}
			
		}
	}
}
